package com.hx.setting.service.imp;

import com.hx.setting.entity.Entity;
import com.hx.setting.entity.User2roleEntity;
import com.hx.setting.model.Condition;
import com.hx.setting.model.GeneratedCriteria;
import com.hx.setting.model.Page;
import com.hx.setting.model.TableField;
import com.hx.setting.model.User2roleModel.User2roleTableField;
import com.hx.setting.model.User2roleModel;
import com.hx.setting.service.BaseService;
import com.hx.setting.service.User2roleService;
import com.hx.setting.service.imp.BaseServiceImp;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Mybatis base dao,封装了对数据库常用操作.
 * Generate Date : 2014-03-16
 * Generate Version : v3.0
 * Generate Name : Honey v3.1 Test
 * Generate User : THINK
 * JDK Version : 1.5
 */
@SuppressWarnings("unchecked")
public class User2roleServiceImp<E extends User2roleEntity, PK extends Serializable> extends BaseServiceImp<E, PK> implements User2roleService<E, PK>
{

	@Override
	public List<E> select(E entity, Page page)
	{
		Condition c = new Condition( new User2roleModel() );
		GeneratedCriteria m = c.or();
		if ( entity.getId() != null )
		{
			m.andEqualTo( User2roleTableField.getInstance( "id" ) ,entity.getId() );
		}
		if ( entity.getUserId() != null )
		{
			m.andEqualTo( User2roleTableField.getInstance( "userId" ) ,entity.getUserId() );
		}
		if ( entity.getRoleId() != null )
		{
			m.andEqualTo( User2roleTableField.getInstance( "roleId" ) ,entity.getRoleId() );
		}
		return baseDao.selectByDynamic( c ,page );
	}

	@Override
	public List<E> select(Map<String, Object> map, Page page)
	{
		Condition c = new Condition( new User2roleModel() );
		GeneratedCriteria m = c.or();
		Enum e = null;
		for ( Map.Entry<String, Object> entity : map.entrySet() )
		{
			e = User2roleTableField.getInstance( entity.getKey() );
			if ( e != null )
			{
				m.andEqualTo( e ,entity.getValue() );
			}
		}
		return baseDao.selectByDynamic( c ,page );
	}

	@Override
	public TableField getTableField(String property)
	{
		return User2roleTableField.getInstance( property );
	}
}
/* Honey v3.1 Test - version:4 - OriginalChecksum:Be4804368499dbf9e3d61078b8526eec8 (do not edit this line) */
